<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <img id="xxx" src="2.jpg" alt="海贼王图片" />
    <script>
      xxx.onload = function () {
        console.log("Success in loading image");
      };
      xxx.onerror = function () {
        console.log("Failed to load image");
        xxx.src = "404.png";
      };
    </script>
  </body>
</html>
